<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>createType | share-open</title>
    <meta name="description" content="函数库，工具库">
    <link rel="stylesheet" href="/share-open/assets/style.9e794c8c.css">
    <link rel="modulepreload" href="/share-open/assets/app.33b585d4.js">
    <link rel="modulepreload" href="/share-open/assets/feature_createType.md.12493caa.lean.js">
    
    <link rel="icon" href="/share-open/favicon.ico">
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
  <meta name="keywords" content="@minionorg,share,函数库,工具库">
  <meta name="twitter:title" content="createType | share-open">
  <meta property="og:title" content="createType | share-open">
  </head>
  <body>
    <div id="app"><div class="layout"><header class="layout-header-wrap clearfix"><div class="logo"><a href="/share-open/">Chestnut-CLI</a></div><ul class="menu-navs clearfix"><li class="nav-item"><a href="/share-open/guide/introduction">指南</a></li><li class="nav-item"><a href="/share-open/feature/code-style">功能</a></li></ul></header><div class="layout-main"><div class="layout-siderbar"><div class="withoutScroll siderbar-wrap"><ul class="siderbar"><!--[--><!--]--></ul></div></div><div class="layout-container"><div class="content chestnut-doc"><div style="position:relative;"><div><h2 id="createtype" tabindex="-1">createType <a class="header-anchor" href="#createtype" aria-hidden="true">#</a></h2><div class="language-js"><pre><code><span class="token function">createType</span><span class="token punctuation">(</span>type<span class="token operator">:</span> string<span class="token punctuation">)</span>
</code></pre></div><p>创建一个对应的类型判断函数</p><h3 id="参数" tabindex="-1">参数 <a class="header-anchor" href="#参数" aria-hidden="true">#</a></h3><ul><li><!----> type — 类型</li></ul><h3 id="返回值" tabindex="-1">返回值 <a class="header-anchor" href="#返回值" aria-hidden="true">#</a></h3><ul><li><!----> 返回对应的类型判断函数</li></ul><h3 id="案例" tabindex="-1">案例 <a class="header-anchor" href="#案例" aria-hidden="true">#</a></h3><div class="language-js"><pre><code><span class="token keyword">const</span> isNumber <span class="token operator">=</span> <span class="token function">createType</span><span class="token punctuation">(</span><span class="token string">&#39;Number&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> isString <span class="token operator">=</span> <span class="token function">createType</span><span class="token punctuation">(</span><span class="token string">&#39;String&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token function">isNumber</span><span class="token punctuation">(</span><span class="token string">&#39;1&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// =&gt; false</span>

<span class="token function">isNumber</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// =&gt; true</span>

<span class="token function">isString</span><span class="token punctuation">(</span><span class="token string">&#39;aa&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// =&gt; true</span>

<span class="token function">createType</span><span class="token punctuation">(</span><span class="token string">&#39;object&#39;</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token literal-property property">a</span><span class="token operator">:</span> <span class="token number">1</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// =&gt; true</span>
</code></pre></div></div></div><div class="layout-antorns"><div class="antorns-wrap"><div class="antorn-container"><div class="antorn-line"><span style="top:8px;" class="antorn-line-i"></span></div><ul class="antorn-list"><!--[--><li class=""><a data-href="#createtype" href="#createtype">createType</a></li><li class=""><a data-href="#参数" href="#参数">参数</a></li><li class=""><a data-href="#返回值" href="#返回值">返回值</a></li><li class=""><a data-href="#案例" href="#案例">案例</a></li><!--]--></ul></div></div></div></div></div></div><div class="footer" data-v-7c92cd43><div class="container" data-v-7c92cd43><div class="footer-main" data-v-7c92cd43><h5 data-v-7c92cd43>Chestnut Design</h5><!--[--><a href="https://github.com/bnuephjx/conventional-changelog-chestnut.git" class="footer-main-link" target="_blank" data-v-7c92cd43><span data-v-7c92cd43>Conventional Changelog Chestnut</span><span class="sub" data-v-7c92cd43> - </span><span class="sub" data-v-7c92cd43>日志模板</span></a><a href="http://bnuephjx.gitee.io/cheatnut-chart-docs-test" class="footer-main-link" target="_blank" data-v-7c92cd43><span data-v-7c92cd43>Chestnut Chart</span><span class="sub" data-v-7c92cd43> - </span><span class="sub" data-v-7c92cd43>3D图表库</span></a><a href=" http://bnuephjx.gitee.io/test_pages" class="footer-main-link" target="_blank" data-v-7c92cd43><span data-v-7c92cd43>Chestnut UI</span><span class="sub" data-v-7c92cd43> - </span><span class="sub" data-v-7c92cd43>未发布可查看</span></a><!--]--></div><div class="footer-main" data-v-7c92cd43><h5 data-v-7c92cd43>社区</h5><a href="https://github.com/ChestnutChina/chestnut-cli/issues" class="footer-main-link" target="_blank" data-v-7c92cd43>问题收集</a></div><div class="footer-main" data-v-7c92cd43><h5 data-v-7c92cd43>友情链接</h5><a href="https://vue3js.cn/docs/zh/" class="footer-main-link" target="_blank" data-v-7c92cd43>Vue</a><a href="https://cli.vuejs.org/" class="footer-main-link" target="_blank" data-v-7c92cd43>Vue CLI</a></div></div><p class="for-the-record" data-v-7c92cd43><img alt="NPM" src="https://img.shields.io/npm/l/chestnut-cli?color=%231890ff&amp;registry_uri=https%3A%2F%2Fregistry.npmjs.com&amp;style=flat-square" data-v-7c92cd43><img alt="Copyright" src="https://img.shields.io/badge/©-Copyright 2021 Chestnut CLI-1890ff?style=flat-square&amp;logo=copyright&amp;logoColor=white" data-v-7c92cd43></p></div></div></div>
    <script>__VP_HASH_MAP__ = JSON.parse("{\"arrayutils_add.md\":\"12eadc14\",\"arrayutils_addall.md\":\"1896209f\",\"arrayutils_clone.md\":\"cd1a015d\",\"arrayutils_remove.md\":\"ed70aa94\",\"charutils_compare.md\":\"090a1d06\",\"charutils_isascii.md\":\"1c949234\",\"charutils_isasciialpha.md\":\"5b47c5ce\",\"charutils_isasciialphalower.md\":\"ff69f581\",\"charutils_isasciialphaupper.md\":\"b57507e4\",\"charutils_isasciialphanumeric.md\":\"aa6cf529\",\"charutils_isasciicontrol.md\":\"145a3d3d\",\"charutils_isasciinumeric.md\":\"164a3c04\",\"charutils_isasciiprintable.md\":\"61dc89b7\",\"charutils_iswhitespace.md\":\"1bd0426f\",\"charutils_tochar.md\":\"655c0c78\",\"charutils_tointvalue.md\":\"82eb682c\",\"charutils_unicodeescaped.md\":\"9c94f2d6\",\"charutils_unicodeunescaped.md\":\"08d91b83\",\"dateutils_dateformathoc.md\":\"1f4f7ba3\",\"dateutils_getdateperiod.md\":\"1d6738ce\",\"dateutils_getdaysinmonth.md\":\"35a00450\",\"dateutils_getfirstdateinmonth.md\":\"6a3659b7\",\"dateutils_getlastdateinmonth.md\":\"2605c753\",\"dateutils_isdate.md\":\"ac6c2ad4\",\"dateutils_isleapyear.md\":\"1c279494\",\"dateutils_istime.md\":\"e2e866e6\",\"dateutils_timeformathoc.md\":\"5af7fb53\",\"numberutils_isfloat.md\":\"4b728517\",\"numberutils_isinteger.md\":\"ccf66170\",\"objectutils_allnotnull.md\":\"ab6eb82e\",\"objectutils_isempty.md\":\"80db2352\",\"stringutils_abbreviate.md\":\"d527170e\",\"stringutils_contains.md\":\"f374c547\",\"stringutils_equals.md\":\"0d8569f3\",\"stringutils_equalsany.md\":\"d3201845\",\"stringutils_equalsanyignorecase.md\":\"7dad0d4a\",\"stringutils_equalsignorecase.md\":\"fbc9c2c5\",\"stringutils_escapehtml.md\":\"0dbcfb0b\",\"stringutils_getstrlength.md\":\"d113eea7\",\"stringutils_isanyempty.md\":\"81b57a10\",\"stringutils_isen.md\":\"9967b5b1\",\"stringutils_isempty.md\":\"948ef7f8\",\"stringutils_iszh.md\":\"2dc14265\",\"stringutils_length.md\":\"745d40f5\",\"stringutils_ltrim.md\":\"63b1c4fa\",\"stringutils_rtrim.md\":\"7bae6965\",\"stringutils_startswith.md\":\"8ec2afa1\",\"stringutils_strip.md\":\"9028e587\",\"stringutils_stripall.md\":\"4b7ce854\",\"stringutils_stripend.md\":\"68b4f5c5\",\"stringutils_stripstart.md\":\"6ef24789\",\"stringutils_striptoempty.md\":\"04f914ea\",\"stringutils_striptonull.md\":\"6f8fee24\",\"stringutils_substring.md\":\"516a7f83\",\"stringutils_substringafter.md\":\"fd65a97b\",\"stringutils_substringafterlast.md\":\"1e8eb540\",\"stringutils_substringbefore.md\":\"b07a29e2\",\"stringutils_substringbeforelast.md\":\"d47b3418\",\"stringutils_substringbetween.md\":\"e6a28dd3\",\"stringutils_substringsbetween.md\":\"77d689b6\",\"stringutils_trim.md\":\"27cf3d51\",\"stringutils_trimtoempty.md\":\"da3c593b\",\"stringutils_trimtonull.md\":\"2ceaf66b\",\"stringutils_truncate.md\":\"618353ac\",\"stringutils_unescapehtml.md\":\"1e0d5bd8\",\"stringutils_uppercase.md\":\"5cc34f14\",\"stringutils_wrap.md\":\"645524e8\",\"stringutils_wrapifmissing.md\":\"29e1ee12\",\"utils_createtype.md\":\"2d1b1499\",\"utils_geturlvaluebykey.md\":\"78c884ed\",\"utils_hasemoji.md\":\"e8a58e7a\",\"utils_isemail.md\":\"ad1e081b\",\"utils_isipv4.md\":\"f14edfec\",\"utils_isipv4range.md\":\"a8d3aa60\",\"utils_isipv6.md\":\"df8c040c\",\"utils_isipv6range.md\":\"55444a01\",\"utils_ismobile.md\":\"63de9138\",\"utils_isphone.md\":\"ec2b2440\",\"utils_isport.md\":\"30bab4ad\",\"utils_ispostalcode.md\":\"b01b9dcb\",\"utils_queryurlparams.md\":\"1a51c028\",\"utils_validatetypehoc.md\":\"e9d07d92\",\"examples_contains_base.md\":\"6e1bbd33\",\"feature_createtype.md\":\"12493caa\",\"guide_faq.md\":\"21c333b1\",\"guide_introduction.md\":\"00f931cc\",\"guide_quickstart.md\":\"10cae443\",\"index.md\":\"b79d3e3d\"}")</script>
    <script type="module" async src="/share-open/assets/app.33b585d4.js"></script>
    
  </body>
</html>